package com.sword.invoice.solon.utils;

import com.sword.common.strategy.ISCommonStrategy;
import org.noear.solon.Solon;

/**
 * @description:
 * @author：Lv.RJ
 * @version: 1.0.0
 * @create: 2025/04/02
 **/
public class SolonContextUtil {
    public static <T extends ISCommonStrategy> T create(String channel, Class<T> clazz) {
        var beansOfType = Solon.context().getBeansOfType(clazz);
        return beansOfType.stream()
                .filter(strategy -> strategy.getChannelCode().equals(channel))
                .findFirst()
                .orElseThrow(() -> new RuntimeException("不支持的能力"));
    }
}
